var a = getApp();

Page({
    data: {
        nav_text: [ "律师简介", "法律服务" ],
        type_name: "",
        text: "",
        lawyer_type: "",
        order_type: "",
        lawyerId: "",
        listServe: [],
        domain_nickName: [],
        lawyerInfo: {},
        lawfirmName: "",
        address: "",
        form: {
            avatar_image: "",
            status: 1,
            introduction: "",
            thumb_image: "",
            address: ""
        },
        addressName: "",
        streetId: "",
        areaId: "",
        cityId: "",
        provinceId: "",
        streetName: "",
        listData: [],
        id: "",
        nav_index: 0
    },
    onLoad: function(a) {
        "lawyer" == a.type_name ? wx.setNavigationBarTitle({
            title: "律师详情"
        }) : wx.setNavigationBarTitle({
            title: "律所详情"
        }), this.setData({
            type_name: a.type_name,
            id: a.id
        }), this.getData();
    },
    toggle_title: function(a) {
        this.setData({
            nav_index: a.currentTarget.dataset.i
        });
    },
    getData: function() {
        var e = this, t = "lawyer" == this.data.type_name ? "plugin.lawyer-platform.frontend.controllers.lawyer.getDetail" : "plugin.lawyer-platform.frontend.controllers.lawyer-firm.getDetail", r = a.getNetAddresss(t), i = this.data.id;
        a._postNetWork({
            url: r,
            data: {
                id: i
            },
            success: function(t) {
                if (1 == t.data.result) {
                    var r = t.data.data.detail;
                    if (e.setData({
                        lawyerInfo: r,
                        domain_nickName: r.category_data
                    }), "office" == e.data.type_name) {
                        var i = t.data.data.detail;
                        e.setData({
                            areaId: i.address.area,
                            cityId: i.address.city,
                            provinceId: i.address.province,
                            "form.avatar_image": i.logo_image,
                            streetId: i.address.stree
                        }), wx.getStorage({
                            key: "provinceData",
                            success: function(a) {
                                var t = wx.getStorageSync("provinceData"), r = wx.getStorageSync("cityData"), n = wx.getStorageSync("districtData"), d = t.filter(function(a) {
                                    return a.id == i.address.province;
                                }), s = r.filter(function(a) {
                                    return a.id == i.address.city;
                                }), o = n.filter(function(a) {
                                    return a.id == i.address.area;
                                }), l = d[0].areaname + s[0].areaname + o[0].areaname;
                                e.setData({
                                    addressName: l
                                });
                            },
                            fail: function(e) {
                                a._getNetWork({
                                    url: a.getNetAddresss("member.member-address.address"),
                                    success: function(a) {
                                        var e = a.data;
                                        console.log(e);
                                        var t = e.data.province, r = e.data.city, i = e.data.district;
                                        wx.setStorage({
                                            key: "provinceData",
                                            data: t
                                        }), wx.setStorage({
                                            key: "cityData",
                                            data: r
                                        }), wx.setStorage({
                                            key: "districtData",
                                            data: i
                                        });
                                    },
                                    fail: function(a) {}
                                });
                            }
                        });
                    } else e.setData({
                        lawfirmName: r.lawyer_firm.name,
                        listServe: r.goods,
                        "form.avatar_image": r.avatar_image
                    });
                    e.setData({
                        "form.status": r.status
                    });
                }
            }
        });
    },
    LinkeOffice: function() {
        wx.navigateTo({
            url: "/packageI/lawyerPlatform/detail/detail?type_name=office&id=" + this.data.lawyerInfo.lf_id
        });
    },
    consult: function(e) {
        var t = e.detail, r = t.service_day, i = t.goods_id, n = t.amount, d = t.consult_type, s = {
            service_day: r,
            goods_id: i,
            l_id: this.data.lawyerInfo.id,
            price: n,
            service_type: 0 == d ? 1 : 2,
            l_name: this.data.lawyerInfo.name,
            lf_id: this.data.lawyerInfo.lf_id,
            lf_name: this.data.lawyerInfo.lawyer_firm.name,
            lf_province_name: this.data.lawyerInfo.lawyer_firm.lf_province_name,
            lf_city_name: this.data.lawyerInfo.lawyer_firm.lf_city_name,
            lf_area_name: this.data.lawyerInfo.lawyer_firm.lf_area_name,
            lf_street_name: this.data.lawyerInfo.lawyer_firm.lf_street_name,
            lf_address_detail: this.data.lawyerInfo.lawyer_firm.address_detail
        }, o = a.getNetAddresss("plugin.lawyer-platform.frontend.controllers.create");
        a._postNetWork({
            url: o,
            data: s,
            success: function(e) {
                1 == e.data.result ? wx.navigateTo({
                    url: "/packageD/buy/orderPay/orderPay?order_id=" + e.data.data.order_ids
                }) : a.tips(e.data.msg);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});